<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopOrderAddressTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('shop_order_address', ['comment' => '订单收货信息', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('order_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '订单'])
            ->addColumn('user_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '用户'])
            ->addColumn('consignee', 'string', ['limit' => 60, 'null' => true, 'default' => null, 'comment' => '收货人'])
            ->addColumn('mobile', 'string', ['limit' => 20, 'null' => true, 'default' => null, 'comment' => '收货手机'])
            ->addColumn('province_name', 'string', ['limit' => 60, 'null' => true, 'default' => null, 'comment' => '省份'])
            ->addColumn('city_name', 'string', ['limit' => 60, 'null' => true, 'default' => null, 'comment' => '城市'])
            ->addColumn('district_name', 'string', ['limit' => 60, 'null' => true, 'default' => null, 'comment' => '地区'])
            ->addColumn('address', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '详细地址'])
            ->addColumn('province_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '省Id'])
            ->addColumn('city_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '市Id'])
            ->addColumn('district_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '区Id'])
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '更新时间'])
            ->addIndex('order_id')
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('shop_order_address');
        $table->drop();
    }
}
